;;; init-input-method.el --- Configuration for chinese input -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:

(with-eval-after-load 'pyim
  (require 'pyim-cregexp-utils)
  (require 'pyim-cstring-utils)
  (require 'pyim-dregcache)

  (setq pyim-cloudim 'baidu
        pyim-prefer-emacs-thread t
        pyim-default-scheme 'quanpin
        pyim-page-style 'one-line
        pyim-page-length 7
        pyim-posframe-min-width 70
        pyim-page-tooltip 'posframe
        pyim-punctuation-translate-p '(auto yes no)
        pyim-indicator-list (list #'pyim-indicator-with-modeline))
  (setq pyim-dcache-backend 'pyim-dregcache)
  (setq pyim-fuzzy-pinyin-alist
        '(("en" "eng") ("in" "ing") ("l" "n") ("z" "zh") ("c" "ch")))

  (define-key pyim-mode-map (kbd ",") #'pyim-page-next-page)
  (define-key pyim-mode-map (kbd ".") #'pyim-page-previous-page)
  (define-key pyim-mode-map (kbd "M-f") #'pyim-page-next-word)
  (define-key pyim-mode-map (kbd "M-b") #'pyim-page-previous-word)
  (define-key pyim-mode-map (kbd "M-c") #'pyim-quit-clear)

  (require 'pyim-tsinghua-dict)
  (pyim-tsinghua-dict-enable))

(with-eval-after-load 'rime
  (setq rime-show-candidate 'posframe)
  (setq rime-posframe-properties '(:internal-border-width 0))
  (setq rime-disable-predicates '(rime-predicate-ace-window-p
                                  rime-predicate-after-alphabet-char-p
                                  rime-predicate-after-ascii-char-p
                                  rime-predicate-hydra-p
                                  rime-predicate-punctuation-after-space-cc-p
                                  rime-predicate-space-after-cc-p
                                  rime-predicate-tex-math-or-command-p)))


(cond ((file-directory-p "/usr/share/rime-data")
       (setq default-input-method "rime")
       (setq rime-title "V"))
      (t
       (setq default-input-method "pyim")))


(provide 'init-input-method)
;;; init-input-method.el ends here
